<?php

namespace mpend\modules\share\controllers;

use Yii;
use mpend\components\Controller;
use mpend\modules\share\models\WorkerJoinForm;
use mpend\modules\share\models\JoinFormOptions;

/**
 * 记工本详情管理
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class JoinController extends Controller {

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['GET'],
            'update' => ['POST'],
        ];
    }

    /**
     * 获取工人表单配置选项
     * @inheritdoc
     */
    public function actionOptions($id) {
        return JoinFormOptions::findOrFail($id);
    }

    /**
     * 添加工人
     * @inheritdoc
     */
    public function actionUpdate($id) {
        $model = new WorkerJoinForm($id);
        $model->user_id = $this->uid;
        $model->load(Yii::$app->request->post(), '');
        return $model->save();
    }

}
